package com.fast.cron.common.utils;

import org.slf4j.LoggerFactory;

/**
 * record log utils
 *
 * @author :leo.jie
 * @version :v1.0
 * @date :2018/10/11 14:24
 */
public class LoggerUtil {

    public static void error(String msg) {
        LoggerFactory.getLogger(getClassName()).error(msg);
    }

    public static void error(String msg, Object... obj) {
        LoggerFactory.getLogger(getClassName()).error(msg, obj);
    }

    public static void warn(String msg) {
        LoggerFactory.getLogger(getClassName()).warn(msg);
    }

    public static void warn(String msg, Object... obj) {
        LoggerFactory.getLogger(getClassName()).warn(msg, obj);
    }

    public static void info(String msg) {
        LoggerFactory.getLogger(getClassName()).info(msg);
    }

    public static void info(String msg, Object... obj) {
        LoggerFactory.getLogger(getClassName()).info(msg, obj);
    }

    public static void debug(String msg) {
        LoggerFactory.getLogger(getClassName()).debug(msg);
    }

    public static void debug(String msg, Object... obj) {
        LoggerFactory.getLogger(getClassName()).debug(msg, obj);
    }


    private static String getClassName() {
        return new SecurityManager() {
            String getClassName() {
                return getClassContext()[3].getName();
            }
        }.getClassName();
    }
}
